import {createRouter, createWebHashHistory, onBeforeRouteUpdate, RouteRecordRaw} from 'vue-router'
import { useNProgress } from '@vueuse/integrations'
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    redirect:'/index',
    // component: () => import('../views/Home.vue')
  },
  {
    path: '/my',
    name: 'My',
    component: () => import( '../views/my.vue')
  },
  {
    path: '/index',
    name: 'Index',
    component: () => import( '../views/index.vue')
  },
  {
    path: '/book-store',
    name: 'bookStore',
    component: () => import( '../views/book-store.vue')
  },
  {
    path: '/book-detail',
    name: 'bookDetail',
    component: () => import( '../views/book-detail.vue')
  },
  {
    path: '/listen-book',
    name: 'listenBook',
    component: () => import( '../views/listen-book.vue')
  },
  {
    path: '/read-book',
    name: 'readBook',
    component: () => import( '../views/read-book.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  // const { isLoading} = useNProgress()
  // console.log(to);
  // // start()
  // isLoading.value = true;
  next();
});

router.afterEach((to, from) => {
  // const { isLoading,done } = useNProgress()
  // done()
});
export default router
